package com.gzy.mylog.net;

import com.gzy.mylog.model.Result;
import com.gzy.mylog.model.User;
import com.gzy.mylog.net.core.XXModelCallback;
import com.gzy.mylog.net.core.XXURLUtils;
import com.gzy.mylog.net.net.ApiCallback;

import java.util.HashMap;
import java.util.Map;

//  网络的业务层
public class AuthApi {


    public static void login(String username, String password, XXModelCallback<Result<String>> apiCallback) {

        Map<String, String> para = new HashMap<>();

        para.put("username",username);
        para.put("password",password);

        XXURLUtils.shared.post(NetConfig.Auth.Login, para, apiCallback);

    }

    public static void signup(String username, String password, XXModelCallback<Result<String>> apiCallback) {

        Map<String, String> para = new HashMap<>();

        para.put("username",username);
        para.put("password",password);

        XXURLUtils.shared.post(NetConfig.Auth.Signup, para, apiCallback);

    }

    public static void loadUserInfo(String token, XXModelCallback<Result<User>> callback)  {

        Map<String, String> header = new HashMap<>();

        header.put("Token",token);

        Map<String, String> para = new HashMap<>();

        XXURLUtils.shared.get(NetConfig.Auth.Userinfo, header,para, callback);

    }
}
